package com.example.dbmysql.service.impl;

import com.example.dbmysql.pojo.Buildings;
import com.example.dbmysql.mapper.buildingsMapper;
import com.example.dbmysql.service.BuildingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Service
public class buildingsServiceImpl implements BuildingsService {

    @Autowired
    private buildingsMapper buildingsMapper;

    @Override
    // 查询
    public Buildings findBuildingsById(Integer id) {
        Buildings b = buildingsMapper.findBuildingsById(id);

        return b;
    }

    @Override
    // 新增楼栋
    public void add(Buildings buildings) {
        buildingsMapper.add(buildings);
    }

    @Override
    public Buildings findBuildingsByBon(String bon) {
        Buildings b = buildingsMapper.findBuildingsByBon(bon);

        return b;
    }

    @Override
    public Buildings updata(Buildings buildings) {
        buildings.setUpdateTimer(LocalDateTime.now());
        buildingsMapper.update(buildings);
        return buildings;
    }

    @Override
    public List<Buildings> getAll(int page,int pageSize) {
        List<Buildings> buildings = buildingsMapper.getAll(page,pageSize);
        return buildings;
    }

    @Override
    public void delbuilingsByid(Integer id) {
        buildingsMapper.delbuilingsByid(id);
    }


}
